import {MainData, PK, pkType, StatusData} from "../../coreModule/data/BaseData";
import {DataOccasion, field, occasion} from "../../coreModule/data/DataLoader";
import {userMgr} from "../../userModule/managers/UserManager";
import {DateUtils} from "../../../utils/DateUtils";
import {TradeAttach} from "./Trade";

export enum BillStatus {
	NotPaid = -2, Paying, Success, Fail, Closed
	// 如果是退款的订单，也是按照该枚举来执行
}

export enum BillType {
	Pay, Refund
}
export enum PayType {
	Balance, WeChat
}

export class Bill extends StatusData<BillStatus> {

	@field(pkType())
	public payerUserId?: PK; // 用户，为空表示系统
	@field(pkType())
	public payeeUserId?: PK; // 商家，为空表示系统
	@field(pkType())
	public tradeId: PK;

	@field(String)
	public prepayId: string;

	@field
	public type: BillType = BillType.Pay;
	@field
	public payType: PayType = PayType.WeChat;

	@field
	public price: number = 0;
	@field
	public realPrice: number = 0;

	@field
	public description: string = "";
	@field(Object)
	public attach: TradeAttach = {};

	@field(Number)
	public createdAt: number;
	@field(Number)
	public successAt: number;

	@field
	public status: BillStatus = BillStatus.NotPaid;

	@field(Object)
	public wxData: any;

}


